// pages/tool/card/make1/print/index/index.js
const app = getApp();
Page({

    /**
     * 页面的初始数据
     */
    data: {
        progress: [2, 2, 2, 2],
        showPage: '',
        id: 0,
        popUp: false
    },

    downloadImg: function () {
        this.setData({ popUp: true });
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        if (options.index == 0) {
            this.setData({
                id: options.id,
                showPage: 0
            }, () => {
                this.papercarddetail(options.id);
            })
        } else {
            this.setData({
                id: options.id,
                showPage: 1
            }, () => {
                this.ecarddetail(options.id);
            })
        }
    },


    //纸质券
    papercarddetail: function (id) {
        app.func.getPromise('/card/papercarddetail/' + id)
            .then(([code, res]) => {
                if (code == 200) {
                    this.setData({data: res.data});
                } else {
                    app.func.toastPromise(res.message)
                }
            })
    },

    //电子券
    ecarddetail: function (id) {
        app.func.postPromise('/distribute/ecarddetail/' + id)
            .then(([code, res]) => {
                if (code == 200) {
                    this.setData({data: res.data});
                } else {
                    app.func.toastPromise(res.message)
                }
            })
    },


    cardlist: function () {
        wx.redirectTo({
            url: '/pages/about/card/distribute/distribute'
        })
    },
    cardOrder:function () {
        wx.redirectTo({
            url:'/pages/about/card/print/print'
        })
    }





})
